home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10866 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: news.ichange.com!newsmaster
  2. From: Jesse Liberty <jl@staff.ichange.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: private base class vs. private member object
  5. Date: Sat, 09 Mar 1996 13:17:34 -0500
  6. Organization: AT&T New Media Services
  7. Message-ID: <3141CB3E.5A36@staff.ichange.com>
  8. References: <4hpqq9$9o3@hackberry.zilker.net> <4hrl32$4b3@newsgate.dircon.co.uk>
  9. NNTP-Posting-Host: 198.112.128.208
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win95; I)
  14.  
  15. Rob and Sylvia Worsnop wrote:
  16. > If you want to access protected methods use private inheritance.
  17. > Some people just use private inheritance anyway because the code
  18. > is often cleaner.
  19. > Whether you use private member objects or private inheritance doesn't
  20. > matter a great deal. The really important thing is not to confuse
  21. > public inheritance and private inheritance.
  22.  
  23. If I understand what you've written, I think I disagree <smile>. 
  24.  
  25. Private inheritance has a specific meaning: it allows you to provide 
  26. "implemented in terms of." That is, when you want to inherit 
  27. implementation but not interface, private inheritance is the solution.
  28.  
  29. Note that an alternative solution in many cases is to use delegation 
  30. through contained classes.  The advantage of private inheritance over 
  31. containment is access to protected members, and perhaps that is what you 
  32. meant, but containment offers other advantages (including the ability to 
  33. have multiple instances of the contained class).
  34.  
  35.  
  36.  
  37.  
  38. -- 
  39. Jesse Liberty. (AT&T New Media Services) jl@staff.ichange.com
  40. Teach Yourself C++ In 21 Days. SAMS, 1994
  41. Teach Yourself MORE C++ In 21 Days. SAMS, 1996
  42. Teach Yourself ANSI C++ In 21 Days. SAMS, 1996
  43. C++: An Introduction To Programming. QUE, 1996
  44.